<template>
  <div class="layout">
    <!-- 左侧导航栏 -->
    <div class="sidebar">
      <div class="logo">
        <h3>食品溯源系统</h3>
      </div>
      <nav class="nav-menu">
        <router-link to="/home" class="nav-item">
          <i class="fas fa-home"></i>
          <span>首页</span>
        </router-link>
        <router-link to="/data" class="nav-item">
          <i class="fas fa-box"></i>
          <span>数据概览</span>
        </router-link>
        <router-link to="/user" class="nav-item">
          <i class="fas fa-search"></i>
          <span>用户管理</span>
        </router-link>
        <router-link to="/food" class="nav-item">
          <i class="fas fa-info-circle"></i>
          <span>食品管理</span>
        </router-link>
      </nav>
    </div>
    
    <!-- 主要内容区 -->
    <div class="main-content">
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: 'MainLayout',
  methods: {
  }
}
</script>

<style scoped>
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background-color: #304156;
  color: white;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
}

.logo {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid #435367;
}

.logo h3 {
  margin: 0;
  color: #fff;
}

.nav-menu {
  flex: 1;
  padding: 20px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  color: #bfcbd9;
  text-decoration: none;
  transition: all 0.3s;
}

.nav-item:hover, .nav-item.router-link-active {
  color: #fff;
  background-color: #263445;
}

.nav-item i {
  margin-right: 10px;
  width: 24px;
  text-align: center;
}

.user-info {
  padding: 20px;
  border-top: 1px solid #435367;
  text-align: center;
}

.logout-btn {
  margin-top: 10px;
  padding: 8px 16px;
  background-color: #dc3545;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  width: 100%;
}

.logout-btn:hover {
  background-color: #c82333;
}

.main-content {
  flex: 1;
  padding: 20px;
  background-color: #f0f2f5;
  overflow-y: auto;
}
</style> 